<?php

namespace App\Http\Controllers\Api\V1;
use App\Models\Account;
use Carbon\Carbon;
use Illuminate\Support\Facades\DB;
use App\Http\Controllers\Api\V1\Resources\AccountResource;
use OpenAI;


class GptController extends Controller
{
	public function index()
	{

		  $yourApiKey = getenv('CHATGPT_API_KEY');
		
		$client = OpenAI::client($yourApiKey);
	
		$result = $client->chat()->create([
		    'model' => 'gpt-3.5-turbo',
		    'messages' => [
		    	['role' => 'system', "content"=> "你是个翻译工作者"],
		        ['role' => 'user', 'content' => '将内容【据都市快报，3月7日，现货黄金来到了2161.25美元/盎司的历史高位，上海黄金交易所Au99.99价格今天继续上探，盘中一度触及506元/克。国内周大福等品牌的足金饰品价格达655元/克，相比一周前每克涨了25元。金价快速上涨也影响了银行的个人黄金业务。3月6日下午，建设银行发布公告称，为顺应市场变化，对个人黄金积存业务进行调整，个人黄金积存业务定期积存起点金额由500元上调至600元。】翻译成英文'],
		    ],
		]);
		//dd($result);
		echo $result->choices[0]->message->content; 
	}


}
